{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
\paperw11900\paperh16840\margl1440\margr1440\vieww14420\viewh16220\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\f0\fs24 \cf0 1. The purpose of categories is to distinguish between different kinds of Instances of the same class. They are used when different behaviour can be expected of the same class in different cases. Only methods should be defined in categories, fields are only defined in the class.\
\
2.  The difference between categories and extensions is, that extensions provide additional functionality whereas categories distinguish between different use cases of a class. The category extends a class in multiple different ways, which would normally contain different methods, because in the case of a method which is implemented in multiple categories, there is no way to determine which of the implementations would be used.\
\
3. The NSMutableString inherits the functionality of the NSString and provides multiple methods for changing the string, such as appendWithString:(NSString*). The NSString can not be changed after being once initialised, the only way to write something new in the object is to initialise it again.\
\
4. Properties are data fields in a class, which upon creation give particular access to a variable through accessors(setters and getters).\
The access to the variable can be restricted with the use of attributes such as readonly or readwrite. The properties can be defined in the interface section of the class and be visible to the outside, or in the implementation section, in which case the can only be accessed from the inside of the class. The difference between properties and instance variables is that the property is a common term for the instance variable and its accessors(setters and getters), if provided.\
\
5.A class method is a method which is not connected to a particular object of the class, it does not operate on any of the object's properties, but provides a common functionality. That is why the class method is invoked on the class, as opposed to the object [
\i className methodName
\i0 ] and not [
\i objectName methodName
\i0 ]. A class method cannot invoke instance methods or use instance variables.\
\
6. Protocols play the role of an interface, which can be used for generalising the functionality of a method for example, so that the method could work on different types of data, without any code repetition. Using  id<
\i protocolName
\i0 > for the parameter type ensures that the compiler would give out warnings when a variable of a type, that does not conform to the said protocol is used to invoke the method. A way to to determine whether an object is of a class that conforms to a given protocol, a message is sent to the object: [
\i objectName 
\i0 conformsToProtocol:@protocol(
\i protocolName
\i0 )]. Protocols define methods ( which can be optional or required, which is default). Each class that adopts the protocol, must implement the methods defined int the protocol (with the exception of optional methods).\
\
7. If the sendMsg method fails to send the appropriate message, which would happen when the object is nil, there is an additional functionality, which could be overridden, but by default does nothing. So nothing will happen when sending a message to a nil object.\
\
8. The principles of OOP are:\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls1\ilvl0\cf0 {\listtext	\'95	}Inheritance\
{\listtext	\'95	}Encapsulation\
{\listtext	\'95	}Abstraction\
{\listtext	\'95	}Polymorphism\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
9. The Encapsulation in OOP is the principle of hiding the data an object holds and regulating access to that data, so that it can be changed, only by authorised places in the system and with valid values. Different possibilities include visible to the outside, visible inside the class only, readonly, inherited in the subclasses.\
\
10. The purpose of initialisers is to divide the allocated memory for an object into pieces, which can hold the information of the objects fields. It also should give initial values to those fields.\
\
11. A designated initialiser is chosen, which should play the role of the main initialiser, invoke the initialiser of the super class as well as give initial values to the class`s fields. All other initialisers normally invoke the designated initialiser, thus creating a chain of init invocations, known as initialiser chaining.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
12. The class is a pattern for the creation of objects, it defines the data and behaviour an object should have. The object is merely an instance of that class, meaning it has all fields  and can perform all operations defined in the class.\
\
13. Both are principles of the object oriented programming. Abstraction is a way of generalising functionality, by way of creating a common class which conforms to certain conditions. The abstraction has the purpose of avoiding code repetition, by reusing existing functionality with multiple different types, which do not even have to be connected in any way. Encapsulation is a way of hiding data, and creating rules for the access to the data. With the use of encapsulation, the permissions for the access to the filed can be given, such as readonly or absolutely hidden from the outside of the class. Additionally setters provide the possibility of validating the data before changing the value of a field.\
\
14. The setter and getter could be overridden when a validation of the input (setter) or a special functionality (different from just returning or assigning the value of a field) is required. The overriding of the accessors is part of the Encapsulation principle. In Obj-C if a property is created and the both the getter and setter are overridden, the compiler assumes that a special functionality is used, and the variable is not actually created, in order to save space.\
\
15. Polymorphism is a principle where it is not known at compile-time which particular implementation of a method would be invoked, because it is not known, what kind of object the message is being sent to, until runtime. This can happen in cases where the Abstraction or Inheritance principles are in use. For example, if a method is overridden in subclasses B and C , and invoked on the superclass A, we would not know until runtime whether the object with type A is initialised as an instance of A, B or C, meaning that any of the implementations(in A, B or c) could potentially be executed.\
\
16. NSMutableDictionary is a collection type, which is used for storing key-value pairs. The key, normally a an NSString is a means of querying for an object. For example, a Dictionary of Users which contains User objects as the value and email or username(unique string) as the key. It is mutable, meaning that similarly to the NSMutableString, NSMutableArray etc. it can be changed, elements can be added, deleted, updated.\
\
17. The time complexity of the Merge Sort is O(N^2). The Algorithm is based on the paradigm "Divide and Conquer", meaning that it recursively divides the array of objects in half. In each recursion step the new array are divided in half until a single item is left. After sorting each of the halts they are being merged into one, which has a time complexity of O(N). This means that there are N recursion steps, each doing an O(N) merging, which gives the algorithm a time complexity of O(N).\
\
18. When passing by reference, the address of the variable is sent to the parameter, so that it (the method) has access to the same space in memory where the variable was originally created. In this case any changes the method makes would be reflected in the original variable. Passing by value means that the copy of the variable is created, which has its own space in memory, is not connected to the original in any way, and changes executed in the method are only applied on the copy and not the original.\
\
19. The super keyword is a way of invoking methods on the superclass. It can be used as a mens of initialiser chaining (For example in the designated initialiser of a class the initialiser of its superclass is called). The self keyword is the way of achieving the so called open recursion, meaning that methods of an object invoke other methods of that same object.\
\
20. Inheritance is a principle of the OOP where classes, called subclasses,  extend a superclass, inheriting its behaviour and data. The inheritance is used in cases where different "sub-kinds" of a class are required, for example the superclass Animal and the subclasses Horse, Dog, Bird, which extend the class animal, inheriting all its methods and properties (public or protected), and adds new ones, characterising each particular animal. The Inheritance is used to avoid code repetition.\
\
21. Comparing 2 objects is done with the message 
\i -(BOOL)isEqual:(id) object
\i0  which returns a YES/NO value. The definition to the method should be overridden for each class so that a logical way of comparing the objects can be defined (In some cases the comparing of only one or two particular fields could be sufficient to claim that two objects are equal).\
\
22. The description method of a class is used to return a literal representation(NSString) of an object. The default functionality returns the name of the object`s class and the address of the object. It is a good idea to override the method, so that it returns useful information about the object (e.g. properties).\
\
23. A static variable is not associated with a single a object, but has the same value for the whole class. An example could be a counter which increments every time a new object of the class is created, that way keeping track of the number of existing objects of that class. Another example could be a container of references to the objects, where every object of the class is being added upon creation.\
\
24. A global variable is a variable that can be accessed from the whole project, as opposed to having a scope and only being used inside of that scope. Constant global variables are used for defining values, such as range limits, initial values, etc. instead of hardcoding values. This way, if a change of a default value is needed, it must be changed in only one place, which could help avoid errors.\
\
25. Extern is used to "Import" a global variable, defined in a class, to another place in the program. For example the definition const char maxGear in the implementation of a class Vehicle, if needed, could be imported into another class or to the main.m with the 
\i extern
\i0  keyword.\
}